package com.domdd.model;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

@Data
@TableName(value = "inventory")
public class Inventory implements Serializable {

    @TableId(type = IdType.AUTO)
    @ApiModelProperty(value = "库存id 主键")
    private Long id;

    @ApiModelProperty(value = "库存数量")
    private Integer quantity;

    @ApiModelProperty(value = "锁定的库存")
    private Integer lockQuantity;

    @ApiModelProperty(value = "可用库存")
    private Integer availableQuantity;

    @ApiModelProperty(value = "次品库存")
    private Integer substandardQuantity;

    @ApiModelProperty(value = "销退在途")
    private Integer saleInOnthewayQuantity;

    @ApiModelProperty(value = "条码")
    private String barcode;

    @ApiModelProperty(value = "商品名称")
    private String goodsName;

    @ApiModelProperty(value = "sku名称")
    private String skuName;

    @ApiModelProperty(value = "品牌")
    private String brandName;

    @ApiModelProperty(value = "商品分类")
    private String categoryName;

    @ApiModelProperty(value = "创建时间")
    private Date createdTime;

    @ApiModelProperty(value = "更新时间")
    private Date lastUpdatedTime;


    @ApiModelProperty(value = "sku编码")
    private String outerId;

    public String getShopCode() {
        return "defaultShopCode";
    }

    public String getProductCode() {
        return outerId;
    }

    public String getProductUnit() {
        return "个";
    }

    @ApiModelProperty(value = "门店编码")
    private String shopCode;
    @ApiModelProperty(value = "产品编码")
    private String productCode;
    @ApiModelProperty(value = "产品单位")
    private String productUnit = "个";
    @ApiModelProperty(value = "仓库类型")
    private String warehouseType = "拼多多旗舰店仓";

    @ApiModelProperty(value = "门店名称")
    private String shopName = "拼多多旗舰店";

    @JSONField(serialize = false)
    private Integer q0;
    @JSONField(serialize = false)
    private Integer q1;
    @JSONField(serialize = false)
    private Integer q2;

    public Integer getQuantity() {
        return q0 - (q1 == null ? 0 : q1) + (q2 == null ? 0 : q2);
    }
}